package com.ug_project.data

/**
 * Created by yeganaaa on 3/18/2017.
 */


/*ئۇچۇر يۈكلىگەندە ئىشلىتىلىدىغان تۈر*/
open class Result<T> {
    open var _ok: (data: T) -> Unit = {}
    open var _err: (err: ErrResult) -> Unit = {}
    open var _loading: () -> Unit = {}
    open var _loaded: () -> Unit = {}
    open var _loadedErr: () -> Unit = {}
    open var _loadedOk: () -> Unit = {}

    open fun err(action: (err: ErrResult) -> Unit) {
        _err = action
    }

    open fun ok(action: (data: T) -> Unit) {
        _ok = action
    }

    open fun loading(action: () -> Unit) {
        _loading = action
    }

    open fun loaded(action: () -> Unit) {
        _loaded = action
    }


    open fun loadedOK(action: () -> Unit) {
        _loadedOk = action
    }

    open fun loadedErr(action: () -> Unit) {
        _loadedErr = action
    }
}

/*خاتالىق نەتىجىسى*/
open class ErrResult {
    open var code: Int = -1
    open var message: String = ""
    open var excepption: Throwable? = null
}
